package com.study.iterator.course;

import java.util.List;

public class IteratorImp<E> implements Iterator<E> {

    private List<E> list;
    private int cursor;
    private E element;

    public IteratorImp(List<E> list) {
        this.list = list;
    }

    @Override
    public E next() {
        System.out.println("当前位置" + cursor);
        element = list.get(cursor++);
        return element;
    }

    @Override
    public boolean hashNext() {
        return cursor!=list.size();
    }
}
